home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’96
/
Better AD security
/
Source
/
ES.h
< prev
next >
Wrap
Text File
|
1996-06-21
|
8KB
|
277 lines
/* NAME:
ES.h
WRITTEN BY:
Dair Grant
DESCRIPTION:
This file documents the interface between your code (the ES Handler,
any custom address table, and your installable routines) and
Extension Shell.
___________________________________________________________________________
*/
#ifndef __EXTENSION_SHELL_1_5__
#define __EXTENSION_SHELL_1_5__
//=============================================================================
// Include files
//-----------------------------------------------------------------------------
#include <Retrace.h>
#include <Shutdown.h>
//=============================================================================
// Defines
//-----------------------------------------------------------------------------
#define kMaxNumIcons 20 // 1..20 icon index
#define kMaxNumCodeResources 10 // 1..10 code resource index
#define kESHandlerCodeType 'Code' // Type of the ES Handler code
#define kAddrsTableCodeType 'Code' // Type of the Address Table code
#define kESHandlerCodeID 5000 // ID of the ES Handler code
#define kAddrsTableCodeID 5001 // ID of the Address Table code
#define kInitialiseParamBlock 0 // Message for the ES Handler code resource
#define kInitialiseAddrsTable 1 // Message for the ES Handler code resource
#define kHandleError 2 // Message for the ES Handler code resource
#define kShiftKey 0x38 // Keycode for the shift key
//=============================================================================
// Structures
//-----------------------------------------------------------------------------
#pragma options align=mac68k
// Six types of code resources are supported right now. Defines to pick them out
// of the union are defined here, with their structures.
#define kTrapPatchType 1 // A Trap Patch
#define kGestaltSelectorType 2 // A Gestalt Selector
#define kShutdownTaskType 3 // A Shutdown Task
#define kVBLTaskType 4 // A VBL Task
#define kLowMemFilterType 5 // A low-mem filter
#define kCodeBlockType 6 // A block of code
#define kTimeManagerTaskType 7 // A Time Manager Task
// TrapPatch information. Trap Patches need to hold the word of the
// trap to patch. Your ES Handler is responsible for ensuring that the
// trap is implemented - if you're patching something really new, or
// something that's implemented by an Extension, you need to test
// for its presence using the IsTrapAvailable routine.
//
// If globalPatch is true, the patch is applied to all applications.
// Otherwise, the patch is applied to the application named in
// appName. (THIS FEATURE IS NOT IMPLEMENTED - THE INFORMATION IS
// HERE AS A TEMPLATE FOR NOW)
typedef struct {
short trapWord;
Boolean globalpatch;
Str31 appName;
} ATrapPatch;
// Gestalt selectors may want to override existing selectors. Set
// overwriteExistingSelector to true if you want your selector
// to replace any existing selector (of type theSelector), and
// false if you want to the existing selector to be left untouched.
typedef struct {
OSType theSelector;
Boolean overwriteExistingSelector;
} AGestaltSelector;
// Shutdown tasks can pass in some flags - defined in Shutdown.h
typedef struct {
short theFlags;
} AShutdownTask;
// Information for a VBL task.
typedef struct {
short vblCount;
short vblPhase;
} AVBLTask;
// Information for a low-mem filter. We need to hold the address
// of the filter to hook ourselves into.
typedef struct {
long theEntryPoint;
} ALowMemFilter;
// Information for a block of code. We don't actually need anything,
// but we can't compile it without having something in the structure.
typedef struct {
long refCon;
} ACodeBlock;
// Information for a Time Manager task. We need to hold the time (in
// milliseconds) before the task is first executed.
typedef struct {
long theDelay;
} ATimeManagerTask;
// Each installable 'thing' is specified via a CodeInfo structure. This holds
// the resource type and id of the code resource (e.g. 'Code', 1000), as well
// as codeType and theCodeThing fields, which specify the type of data in
// theCodeThing and type-specific data respectively.
//
// theAddress is an internal Extension Shell field, used to hold the
// address of the thing installed/the thing that was replaced by the
// thing installed (the meaning differs, depending on the type of 'the thing'.
//
// theAddress is read only.
typedef struct {
OSType resType; // Resource type of thing
short resID; // Resource ID of thing
short codeType; // Type of this thing
union {
ATrapPatch theTrapPatch;
AGestaltSelector theGestaltSelector;
AShutdownTask theShutdownTask;
AVBLTask theVBLTask;
ALowMemFilter theLowMemFilter;
ACodeBlock theCodeBlock;
ATimeManagerTask theTimeManagerTask;
} theCodeThing; // Specific details for this thing
Ptr theAddress; // USED BY EXTENSION SHELL
} CodeInfo;
// The ParamBlock. All communication between your code and Extension Shell is done
// through a pointer to one of these structures. Relevent sections are grouped
// together.
typedef struct {
// Misc (Extension Shell <--> ES Handler)
//
// systemVersion holds 7.0.0 as 0x0700, 7.5.2 as 0x0752, etc.
// NotificationMsg allows you to install Notification Manager requests.
// IsKeyMouseDown checks for a key/the mouse being pressed.
// IsTrapAvailable checks for the presence of a trap.
// IsPowerMac returns true/false as the Mac CPU is 68K/PPC.
// IsTrapNative returns true/false as a given trap is fat.
long systemVersion;
pascal void (*NotificationMsg)(short errStrings, short theErr);
pascal Boolean (*IsKeyMouseDown)(short keyCode, Boolean checkMouse);
pascal Boolean (*IsTrapAvailable)(short trapWord);
pascal Boolean (*IsPowerMac)(void);
pascal Boolean (*IsTrapNative)(short trapWord);
// Icons (Extension Shell <-- ES Handler)
//
// numIcons contains the number of valid entries in theIcons, from 0..N.
// animationDelay is the number of ticks to wait between showing icons.
// theIcons is an array of the resource IDs of the icons to show.
short numIcons;
short animationDelay;
short theIcons[kMaxNumIcons+1];
// Address Table (Extension Shell <-- ES Handler)
//
// installAddressTable indicates if your Extension wants an address table.
// addressTableSelector indicates the selector for your address table.
Boolean installAddressTable;
OSType addressTableSelector;
// Modules To Install (Extension Shell <-- ES Handler)
//
// numCodeResources contains the number of valid entries in theCodeResources.
// theCodeResources contains the information for each code resource to install.
int numCodeResources;
CodeInfo theCodeResources[kMaxNumCodeResources+1];
// Error Handling (Extension Shell --> ES Handler)
//
// errorIndex contains the entry in theCodeResources which could not be installed.
// theErr contains the reason why theCodeResources[errorIndex] failed.
short errorIndex;
OSErr theErr;
// Error Reporting (Extension Shell <-- ES Handler)
//
// removeInstalledCode indicates if Extension Shell should try an uninstall.
// beepNow indicates if Extension Shell should beep now.
// postError indicates if Extension Shell should install a Notification Manager message.
// errorStringsID contains the 'STR#' resource ID for a Notification Manager message.
// errorStringsIndex contains the string index for a Notification Manager message.
Boolean removeInstalledCode;
Boolean beepNow;
Boolean postError;
short errorStringsID;
short errorStringIndex;
} ESParamBlock;
#pragma options align=reset
//=============================================================================
// Function pointer types
//-----------------------------------------------------------------------------
typedef void (*ESHandlerProc)(short theMsg, ESParamBlock *theParamBlock);
#endif